package com.ruoyi.web.controller.gatewayManagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ReservationTask;
import com.ruoyi.system.service.IReservationTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 下载预约OTAController
 * 
 * @author LGD
 * @date 2025-07-25
 */
@RestController
@RequestMapping("/gatewayManagement/task")
public class ReservationTaskController extends BaseController
{
    @Autowired
    private IReservationTaskService reservationTaskService;

    /**
     * 查询下载预约OTA列表
     */
    @PreAuthorize("@ss.hasPermi('system:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReservationTask reservationTask)
    {
        startPage();
        List<ReservationTask> list = reservationTaskService.selectReservationTaskList(reservationTask);
        return getDataTable(list);
    }

    /**
     * 导出下载预约OTA列表
     */
    @PreAuthorize("@ss.hasPermi('system:task:export')")
    @Log(title = "下载预约OTA", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReservationTask reservationTask)
    {
        List<ReservationTask> list = reservationTaskService.selectReservationTaskList(reservationTask);
        ExcelUtil<ReservationTask> util = new ExcelUtil<ReservationTask>(ReservationTask.class);
        util.exportExcel(response, list, "下载预约OTA数据");
    }

    /**
     * 获取下载预约OTA详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:task:query')")
    @GetMapping(value = "/{reservationTaskId}")
    public AjaxResult getInfo(@PathVariable("reservationTaskId") Long reservationTaskId)
    {
        return success(reservationTaskService.selectReservationTaskByReservationTaskId(reservationTaskId));
    }

    /**
     * 新增下载预约OTA
     */
    @PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "下载预约OTA", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReservationTask reservationTask)
    {
        return toAjax(reservationTaskService.insertReservationTask(reservationTask));
    }

    /**
     * 修改下载预约OTA
     */
    @PreAuthorize("@ss.hasPermi('system:task:edit')")
    @Log(title = "下载预约OTA", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReservationTask reservationTask)
    {
        return toAjax(reservationTaskService.updateReservationTask(reservationTask));
    }

    /**
     * 删除下载预约OTA
     */
    @PreAuthorize("@ss.hasPermi('system:task:remove')")
    @Log(title = "下载预约OTA", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reservationTaskIds}")
    public AjaxResult remove(@PathVariable Long[] reservationTaskIds)
    {
        return toAjax(reservationTaskService.deleteReservationTaskByReservationTaskIds(reservationTaskIds));
    }



}
